package com.jeff.tianti.cms.dao;

import com.jeff.tianti.common.dao.CustomBaseSqlDaoImpl;
import com.jeff.tianti.common.entity.PageModel;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jeff.tianti.cms.entity.AwardsToDeclare;
import com.jeff.tianti.cms.dto.AwardsToDeclareQueryDTO;
import org.apache.commons.lang3.StringUtils;

/**
 * @author xujianfang
 * @desc AwardsToDeclareDaoImpl�� 
 * @date 2019-07-05
 */

public class AwardsToDeclareDaoImpl extends CustomBaseSqlDaoImpl implements AwardsToDeclareDaoCustom  {

    public PageModel<AwardsToDeclare> queryAwardsToDeclarePage(AwardsToDeclareQueryDTO awardsToDeclareQueryDTO){
         Map<String,Object> map = new HashMap<String,Object>();
         StringBuilder hql = new StringBuilder();
         hql.append("select t from AwardsToDeclare t where 1 = 1 ");
        if (awardsToDeclareQueryDTO != null) {
            String auditFlag = awardsToDeclareQueryDTO.getAuditFlag();
            if (StringUtils.isNotBlank(auditFlag)  && !"-1".equals(auditFlag)) {
                hql.append(" and t.auditFlag = :auditFlag ");
                map.put("auditFlag", auditFlag);
            }
        }
        hql.append(" order by t.createDate desc ");

        return this.queryForPageWithParams(hql.toString(),map,awardsToDeclareQueryDTO.getCurrentPage(),awardsToDeclareQueryDTO.getPageSize());
    }

    public List<AwardsToDeclare> queryAwardsToDeclareList(AwardsToDeclareQueryDTO awardsToDeclareQueryDTO){
         Map<String,Object> map = new HashMap<String,Object>();
         StringBuilder hql = new StringBuilder();
         hql.append("select t from AwardsToDeclareTo t ");
         return this.queryByMapParams(hql.toString(),map);
    }


}